package com.huirui.server.pojo.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;

@Data
@Schema(description = "商品编辑视图对象，用于接收和返回商品编辑相关数据")
@Accessors(chain = true)
public class ProductEditVo {

    @Schema(description = "商品ID（新增时可不传，修改时必传）", example = "1001")
    private Long productId;

    @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "医用外科口罩")
    private String productName;

    @Schema(description = "商品描述", example = "三层防护，透气舒适")
    private String productDescription;

    @Schema(description = "所属分类ID列表", example = "[101, 203]")
    private List<Long> categoryIds;

    @Schema(description = "商品主图URL", example = "https://example.com/images/main.jpg")
    private String productImage;

    @Schema(description = "商品状态（0-下架，1-上架）", example = "1", allowableValues = {"0", "1"})
    private Integer productStatus;

    @Schema(description = "商品权重（用于排序，数值越大优先级越高）", example = "5")
    private Integer weight;

    @Schema(description = "轮播图URL列表", example = "[\"https://example.com/banner1.jpg\", \"https://example.com/banner2.jpg\"]")
    private List<String> bannerImages;

    @Schema(description = "详情图URL列表", example = "[\"https://example.com/detail1.jpg\", \"https://example.com/detail2.jpg\"]")
    private List<String> detailImages;

    @Schema(description = "生产企业", example = "XX医疗器械有限公司")
    private String manufacturingEnterprise;

    @Schema(description = "商品品牌", example = "健康防护")
    private Long brandId;

    @Schema(description = "商品包装规格", example = "50片/盒")
    private String productPackaging;

    @Schema(description = "注册证编号", example = "粤械注准2020XXXXXXX")
    private String registrationNumber;

    @Schema(description = "医保编号", example = "YB2023XXXX")
    private String medicalInsuranceNumber;

    @Schema(description = "注册证照片URL", example = "https://example.com/reg-cert.jpg")
    private String registrationIdPhoto;

    @Schema(description = "生产日期", example = "2023-01-15")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate manufacturingDate;

    @Schema(description = "有效期至", example = "2025-01-14")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate expiryDate;


    @Schema(description = "商品规格列表")
    private List<ProductSpecificationVo> productSpecifications;

    @Schema(description = "库存计数方式（0-手动计数，1-自动计数）", example = "0", allowableValues = {"0", "1"})
    private Integer inventoryCountingMethod;

    @Data
    @Schema(description = "商品规格子对象，包含具体规格的价格、库存等信息")
    public static class ProductSpecificationVo {

        @Schema(description = "规格ID（新增时可不传，修改时必传）", example = "2001")
        private Long productSpecificationId;

        @Schema(description = "规格名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "成人款-50片/盒")
        private String productSpecificationName;

        @Schema(description = "规格图片URL", example = "https://example.com/spec1.jpg")
        private String productSpecificationImage;

        @Schema(description = "折扣价（元）", example = "29.9")
        private Double discountPrice;

        @Schema(description = "原价（元）", example = "39.9")
        private Double originalPrice;

        @Schema(description = "秒杀价格")
        private Double seckillPrice;

        @Schema(description = "排序优先级（数值越小越靠前）", example = "1")
        private Integer sort;

        @Schema(description = "销量")
        private Long saleCount;

        @Schema(description = "促销价格")
        private BigDecimal promotionalPrice;

        @Schema(description = "库存数量", example = "1000")
        private Long stock;
    }
}